package viewcomponents;

import java.awt.event.ActionEvent;
import java.io.IOException;

import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import view.SLogoView;

public class SLogoMenu 
{
	private JMenuBar myMenuBar;
	private SLogoTabManager myTabManager;

	public SLogoMenu()
	{
		myMenuBar = this.createMenu();
	}
	
	public JMenuBar getMenuBar()
	{
		return myMenuBar;
	}
	
	public void setTab(SLogoTabManager manager)
	{
		myTabManager = manager;
	}
	
	private JMenuBar createMenu()
	{
		JMenuBar menuBar;
        JMenu menu;

        //Create the menu bar.
        menuBar = new JMenuBar();

        //Build the first menu.
        menu = new JMenu("File");
        menuBar.add(menu);

//      a group of JMenuItems
//        menu.add(new AbstractAction("New")
//        {
//        	@Override
//        	public void actionPerformed (ActionEvent e) {
//        		try {
//					new SLogoView();
//				} catch (IOException e1) {
//					// TODO Auto-generated catch block
//					e1.printStackTrace();
//				}
//        	}
//        });
        
        menu.add(new AbstractAction("New")
        {
			@Override
			public void actionPerformed(ActionEvent e) {
				myTabManager.addTab("New Tab");
			}
        });
        
        JMenuItem save = new JMenuItem("Save");
        menu.add(save);
        
        //a group of JMenuItems
        
        menu.add(new AbstractAction("Quit")
        {
            public void actionPerformed (ActionEvent e)
            {
                System.exit(0); // end program
            }
        });
		
        return menuBar;
	}
	
	
}
